package com.techwells.applicationMarket.util.message;

import com.techwells.applicationMarket.dao.MessageMapper;
import com.techwells.applicationMarket.domain.Message;
import com.techwells.applicationMarket.exception.GlobalException;
import com.techwells.applicationMarket.properties.ConfigProperties;
import com.techwells.applicationMarket.util.Jpush;

/**
 * 推送消息的工具类
 * @author 爱撒谎的男孩
 */
public class PushMessageUtils {
	/**
	 * 推送消息
	 * @param msg  消息内容
	 */
	public static void pushMessage(MessageMapper messageMapper,Message message,ConfigProperties configProperties) {
		int count = messageMapper.insertSelective(message);
		if (count==0) {
			throw new GlobalException("-1", "消息推送失败");
		}
		
		//推送消息
		Jpush.jiguangPush(message.getToUser()+"", message.getContent(), configProperties.getMessageType().getWalletMessageType());
		
	}
}
